//
//  LLNoCompletedCell.m
//  UserUse
//
//  Created by Yiwi on 16/10/18.
//  Copyright © 2016年 CJPC. All rights reserved.
//

#import "LLCompletedCell.h"

@interface LLCompletedCell (){
    UILabel * _stateLabel;
    UILabel * _dectionLabel;
    UILabel * _dection;
    UILabel * _dateLabel;
    UILabel * _countLabel;
    UILabel * _moneyLabel;
    UILabel * _money;
}

@end

@implementation LLCompletedCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
       [self setupSubView];
    }
    return self;
}

-(void)setupSubView{
    self.backgroundColor = kColoeString(@"#dedede");
    
    UIView * topLayerView = [UIView new];
    topLayerView.backgroundColor = kColoeString(@"f4f4f4");
    [self addSubview:topLayerView];
    
    UIView *topLine = [UIView new];
    topLine.backgroundColor = kColoeString(@"#dedede");
    [topLayerView addSubview:topLine];
    
    UIView * topView = [UIView new];
    topView.backgroundColor = [UIColor whiteColor];
    [self addSubview:topView];
    
    UIView * midView = [UIView new];
    midView.backgroundColor = [UIColor whiteColor];
    [self addSubview:midView];
    
    _stateLabel = [UILabel new];
    _stateLabel.text = @"未完成订单";
    _stateLabel.textColor = kColoeString(@"#333333");
    _stateLabel.font = [UIFont systemFontOfSize:15];
    [topView addSubview:_stateLabel];
    
    _dectionLabel = [UILabel new];
    _dectionLabel.textColor = kColoeString(@"#333333");
    _dectionLabel.font = [UIFont systemFontOfSize:15];
    [midView addSubview:_dectionLabel];
    
    UIImageView * lineIV = [UIImageView new];
    lineIV.image = [UIImage imageNamed:@"shortArrow"];
    [midView addSubview:lineIV];
    
    _dection = [UILabel new];
    _dection.textColor = kColoeString(@"#333333");
    _dection.font = [UIFont systemFontOfSize:15];
    [midView addSubview:_dection];
    
    _dateLabel = [UILabel new];
    _dateLabel.textColor = kColoeString(@"#666666");
    _dateLabel.font = [UIFont systemFontOfSize:14];
    [midView addSubview:_dateLabel];
    
    _countLabel = [UILabel new];
    _countLabel.textColor = kColoeString(@"#666666");
    _countLabel.font = [UIFont systemFontOfSize:12];
    [midView addSubview:_countLabel];
    
    
    _moneyLabel = [UILabel new];
    _moneyLabel.textColor = kColoeString(@"#666666");
    _moneyLabel.font = [UIFont systemFontOfSize:12];
    [midView addSubview:_moneyLabel];
    
    _money = [UILabel new];
    _money.textColor = kColoeString(@"#ff3333");
    _money.font = [UIFont systemFontOfSize:12];
    [midView addSubview:_money];

    UIView *bottomLine = [UIView new];
    bottomLine.backgroundColor = kColoeString(@"#dedede");
    [midView addSubview:bottomLine];
    
    
    UILabel * label = [UILabel new];
    label.text = @"一个人的费用已由司机代付";
    label.textColor = kColoeString(@"#ff3333");
    label.font = [UIFont systemFontOfSize:15];
    [midView addSubview:label];
    
    [topLayerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(0);
        make.height.equalTo(@(kScaleNum(5)));
    }];
    
    [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(0);
        make.height.equalTo(@(kScaleNum(.5)));
        
    }];
    
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topLayerView.mas_bottom);
        make.left.right.mas_equalTo(0);
        make.height.equalTo(@(kScaleNum(25)));
    }];
    
    [midView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topView.mas_bottom).offset(kScaleNum(.5));
        make.left.right.mas_equalTo(0);
        make.height.equalTo(@(kScaleNum(110)));
    }];
    
    [_stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(topView.mas_left).offset(kScaleNum(10));
        make.centerY.equalTo(topView.mas_centerY);
    }];
    
    [_dectionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_stateLabel);
        make.top.equalTo(midView.mas_top).offset(kScaleNum(10));
        make.width.lessThanOrEqualTo(@(kScreenFrameW/2-kScaleNum(40)));
    }];
    
    [lineIV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_dectionLabel.mas_right).offset(kScaleNum(10));
        make.centerY.equalTo(_dectionLabel.mas_centerY);
        make.width.equalTo(@(kScaleNum(25)));
        make.height.equalTo(@(kScaleNum(7)));
    }];
    
    [_dection mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lineIV.mas_right).offset(kScaleNum(7));
        make.centerY.equalTo(_dectionLabel.mas_centerY);
        make.width.lessThanOrEqualTo(@(kScreenFrameW/2-kScaleNum(40)));
    }];
    
    [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_dectionLabel.mas_bottom).offset(kScaleNum(3));
        make.left.mas_equalTo(_stateLabel);
        make.width.lessThanOrEqualTo(@(kScreenFrameW-kScaleNum(20)));
    }];
    
    [_countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_dateLabel.mas_bottom).offset(kScaleNum(3));
        make.left.mas_equalTo(_stateLabel);
        make.width.lessThanOrEqualTo(@(kScreenFrameW-kScaleNum(20)));
    }];
    
    [_moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_countLabel.mas_bottom).offset(kScaleNum(3));
        make.left.mas_equalTo(_stateLabel);
    }];
    
    [_money mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_moneyLabel.mas_right).offset(kScaleNum(3));
        make.centerY.equalTo(_moneyLabel.mas_centerY);
    }];
    
    [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_money.mas_bottom).offset(kScaleNum(1));
        make.height.equalTo(@(kScaleNum(.5)));
        make.left.right.mas_equalTo(0);
    }];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bottomLine.mas_bottom).offset(kScaleNum(3));
        make.left.equalTo(midView.mas_left).offset(kScaleNum(10));
     }];
    
}

-(void)setupDataWithOrderlist:(HomeOrderModel*)orderList{
    _dectionLabel.text = orderList.route_s;
    _dection.text = orderList.route_e;
    NSString * timeString = [NSString stringWithFormat:@"%@",orderList.date_s];
    _dateLabel.text = timeString;
    _countLabel.text = [NSString stringWithFormat:@"拼车人数： %d",orderList.order_num];
    _moneyLabel.text = @"拼车费用：";
    int orderNum = orderList.order_num;
    if (orderNum == 0) {
        orderNum = 1;
    }
    _money.text =[NSString stringWithFormat:@"%@元",[NSString stringWithFormat:@"%d",[orderList.order_amt intValue]/orderNum]];
}

@end
